package cn.graydove.bot.service.impl;

import cn.graydove.bot.data.GroupServiceCacheData;
import cn.graydove.bot.repository.AdvanceRepository;
import cn.graydove.bot.service.AdvanceService;
import cn.graydove.bot.service.ScheduledService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ScheduledServiceImpl implements ScheduledService {

    private GroupServiceCacheData groupServiceCacheData;

    private AdvanceService advanceService;

    public ScheduledServiceImpl(GroupServiceCacheData groupServiceCacheData, AdvanceService advanceService) {
        this.groupServiceCacheData = groupServiceCacheData;
        this.advanceService = advanceService;
    }

    /**
     * second, minute, hour, day of month,mouth, day of week
     */
    @Override
    @Scheduled(cron = "0 0 5 * * ?")
    public void clear() {
        log.info("清空出刀数据");
        groupServiceCacheData.clearAttack();
    }

    @Override
    @Scheduled(cron = "0 0 5 * * ?")
    public void clearImg() {
        log.info("清空出刀数据图片请求数量");

        advanceService.clearImg();
    }

}
